#include <iostream>
#include <cstring>
#include <cerrno>
#include "commen.hpp"

int main()
{
    //关联共享内存
    key_t key = getKey();
    int shmid = getShm(key);
    char *s = (char *)shmat(shmid, nullptr, 0);

    //打开写端
    int fd = open(filename.c_str(), O_WRONLY);

    // 开始进程间通信
    for (char ch = 'a'; ch < 'z'; ch++)
    {
        s[ch - 'a'] = ch;
        std::cout << "write: " << ch << " done" << std::endl;
        sleep(2);

        //通知对端
        int code = 0;
        write(fd, &code, sizeof(code));
    }

    shmdt(s);

    return 0;
}